﻿<%@ page language="java" import="com.newcrm.config.Const,com.newcrm.util.Util,com.newcrm.bean.*,java.util.List,java.util.Map" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
  User user = (User) session.getAttribute("user");
  Map<Integer, CompanyInfo> companys = (Map<Integer, CompanyInfo>) application.getAttribute(Const.APPLICATION_COMPANYS);
  CompanyInfo companyInfo = companys.get(Integer.valueOf(user.companyId));
  List<User> users = companyInfo.users;
%>
<div class="searchbar" id="searchbar">
  <a class="closebtn" href="#" id="adv-search-close"><i class="fa fa-times"></i></a>
  <h1><i class="fa fa-search"></i> 点击下面的字段设置搜索条件</h1>
  <ul>
    <li>
      <div class='popbox'>
        <a class='open' href='#'>名称</a>
        <div class='collapse'>
          <div class='box'>
            <div class='arrow'></div><div class='arrow-border'></div>
            <form name="name" valueType="<%=Const.FIELD_TYPE_TEXT%>" id="search_condition_name_form">
              <p class="fields">
                <input class="filter" name="name" type="text" id="search_condition_name" /> <input name="commit" class="button" type="submit" value="查找" />
                <small>提示：输入公司或联系人姓名</small>
              </p>
            </form>
          </div>
        </div>
      </div>
    </li>

    <li>
      <div class='popbox'>
        <a class='open' href='#'>职位</a>
        <div class='collapse'>
          <div class='box'>
            <div class='arrow'></div><div class='arrow-border'></div>
            <form name="title" valueType="<%=Const.FIELD_TYPE_TEXT%>">
              <p class="fields">
                <input class="filter" name="title" type="text" /> <input name="commit" class="button" type="submit" value="查找" />
                <small>提示:输入联系人的职位</small>
              </p>
            </form>
          </div>
        </div>
      </div>
    </li>

    <li>
      <div class='popbox'>
        <a class='open' href='#'>邮箱</a>
        <div class='collapse'>
          <div class='box'>
            <div class='arrow'></div><div class='arrow-border'></div>
            <form name="email" valueType="<%=Const.FIELD_TYPE_TEXT%>">
              <p class="fields">
              <input class="filter" name="email" type="text" /> <input name="commit" class="button" type="submit" value="查找" />
              </p>
            </form>
          </div>
        </div>
      </div>
    </li>

    <li>
      <div class='popbox'>
        <a class='open' href='#'>电话/传真</a>
        <div class='collapse'>
          <div class='box'>
            <div class='arrow'></div><div class='arrow-border'></div>
            <form name="phone" valueType="<%=Const.FIELD_TYPE_TEXT%>">
              <p class="fields">
                <input class="filter" name="phone" type="text" /> <input name="commit" class="button" type="submit" value="查找" />
                <small>提示:输入联系人的电话/手机/传真</small>
              </p>
            </form>
          </div>
        </div>
      </div>
    </li>

    <li>
      <div class='popbox'>
        <a class='open' href='#'>城市</a>
        <div class='collapse'>
          <div class='box'>
            <div class='arrow'></div><div class='arrow-border'></div>
            <form name="formArea" valueType="<%=Const.FIELD_TYPE_TEXT%>">
              <p class="fields">
                <select name="province" onchange="changeProvince($(this), false);">
                <option value="">省份</option><option value="安徽">安徽</option><option value="北京">北京</option><option value="福建">福建</option><option value="甘肃">甘肃</option><option value="广东">广东</option><option value="广西">广西</option><option value="贵州">贵州</option><option value="海南">海南</option><option value="河北">河北</option><option value="河南">河南</option><option value="黑龙江">黑龙江</option><option value="湖北">湖北</option><option value="湖南">湖南</option><option value="吉林">吉林</option><option value="江苏">江苏</option><option value="江西">江西</option><option value="辽宁">辽宁</option><option value="内蒙古自治区">内蒙古</option><option value="宁夏回族自治区">宁夏</option><option value="青海">青海</option><option value="山东">山东</option><option value="山西">山西</option><option value="陕西">陕西</option><option value="上海">上海</option><option value="四川">四川</option><option value="天津">天津</option><option value="西藏自治区">西藏</option><option value="新疆维吾尔自治区">新疆</option><option value="云南">云南</option><option value="浙江">浙江</option><option value="重庆">重庆</option><option value="中国香港">香港</option><option value="中国台湾">台湾</option><option value="中国澳门">澳门</option>
                </select>
                <select name="city"><option value="">城市</option></select> <input name="commit" class="button" type="submit" value="查找" />
              </p>
            </form>
          </div>
        </div>
      </div>
    </li>

    <li>
      <div class='popbox'>
        <a class='open' href='#'>地址</a>
        <div class='collapse'>
          <div class='box'>
            <div class='arrow'></div><div class='arrow-border'></div>
            <form name="address" valueType="<%=Const.FIELD_TYPE_TEXT%>">
              <p class="fields">
                <input class="filter" name="address" type="text" /> <input name="commit" class="button" type="submit" value="查找" />
              </p>
            </form>
          </div>
        </div>
      </div>
    </li>

    <li>
      <div class='popbox'>
        <a class='open' href='#'>简介</a>
        <div class='collapse'>
          <div class='box'>
            <div class='arrow'></div><div class='arrow-border'></div>
            <form name="background" valueType="<%=Const.FIELD_TYPE_TEXT%>">
              <p class="fields">
                <input class="filter" name="background" type="text" /> <input name="commit" class="button" type="submit" value="查找" />
              </p>
            </form>
          </div>
        </div>
      </div>
    </li>

    <li>
      <div class='popbox'>
        <a class='open' href='#'>创建时间</a>
        <div class='collapse'>
          <div class='box'>
            <div class='arrow'></div><div class='arrow-border'></div>
            <form name="createDate" valueType="<%=Const.FIELD_TYPE_DATE%>">
              <p class="fields">
                <input type="text" id="createDate" class="filter daterangepickerinput" value="" /> <input name="commit" class="button" type="submit" value="查找" />
              </p>
            </form>
          </div>
        </div>
      </div>
    </li>

    <li>
      <div class='popbox'>
        <a class='open' href='#'>分配时间</a>
        <div class='collapse'>
          <div class='box'>
            <div class='arrow'></div><div class='arrow-border'></div>
            <form name="assignDate" valueType="<%=Const.FIELD_TYPE_DATE%>">
              <p class="fields">
                <input type="text" id="assignDate" class="filter daterangepickerinput" value="" /> <input name="commit" class="button" type="submit" value="查找" />
              </p>
            </form>
          </div>
        </div>
      </div>
    </li>

    <li>
      <div class='popbox'>
        <a class='open' href='#'>最后联系时间</a>
        <div class='collapse'>
          <div class='box'>
            <div class='arrow'></div><div class='arrow-border'></div>
            <form name="lastContactDate" valueType="<%=Const.FIELD_TYPE_DATE%>">
              <p class="fields">
                <input type="text" id="lastContactDate" class="filter daterangepickerinput" value="" /> <input name="commit" class="button" type="submit" value="查找" />
              </p>
            </form>
          </div>
        </div>
      </div>
    </li>

    <li>
      <div class='popbox'>
        <a class='open' href='#'>下次联系时间</a>
        <div class='collapse'>
          <div class='box'>
            <div class='arrow'></div><div class='arrow-border'></div>
            <form name="nextContactDate" valueType="<%=Const.FIELD_TYPE_DATE%>">
              <p class="fields">
                <input type="text" id="nextContactDate" class="filter daterangepickerinput" value="" /> <input name="commit" class="button" type="submit" value="查找" />
              </p>
            </form>
          </div>
        </div>
      </div>
    </li>

    <li>
      <div class='popbox'>
        <a class='open' href='#'>聊天工具</a>
        <div class='collapse'>
          <div class='box'>
            <div class='arrow'></div><div class='arrow-border'></div>
            <form name="im" valueType="<%=Const.FIELD_TYPE_TEXT%>">
              <p class="fields">
                <input class="filter" name="im" type="text" /> <input name="commit" class="button" type="submit" value="查找" />
              </p>
            </form>
          </div>
        </div>
      </div>
    </li>

    <li>
      <div class='popbox'>
        <a class='open' href='#'>最后联系员工</a>
        <div class='collapse'>
          <div class='box'>
            <div class='arrow'></div><div class='arrow-border'></div>
            <form name="formUpdateUserId" valueType="<%=Const.FIELD_TYPE_SELECT%>">
              <p class="fields">
                <select name="updateUserId">
                  <option value="<%=user.userId%>">我</option>
<%
                  for (User u : users) {
                    if (u.userId.equals(user.userId)) {
                      continue;
                    }
                    if (!companyInfo.isGroupAdmin(user, u.groupId)) {
                      continue;
                    }
                    %>
                  <option value="<%=u.userId%>"><%=Util.HTMLEncode(u.name)%></option>
<%                }%>
                </select>
                 <input name="commit" class="button" type="submit" value="查找" />
              </p>
            </form>
          </div>
        </div>
      </div>
    </li>

    <li>
      <div class='popbox'>
        <a class='open' href='#'>创建员工</a>
        <div class='collapse'>
          <div class='box'>
            <div class='arrow'></div><div class='arrow-border'></div>
            <form name="formCreateUserId" valueType="<%=Const.FIELD_TYPE_SELECT%>">
              <p class="fields">
                <select name="createUserId">
                  <option value="<%=user.userId%>">我</option>
<%
                  for (User u : users) {
                    if (u.userId.equals(user.userId)) {
                      continue;
                    }
                    if (!companyInfo.isGroupAdmin(user, u.groupId)) {
                      continue;
                    }
                    %>
                  <option value="<%=u.userId%>"><%=Util.HTMLEncode(u.name)%></option>
<%                }%>
                </select>
                 <input name="commit" class="button" type="submit" value="查找" />
              </p>
            </form>
          </div>
        </div>
      </div>
    </li>

<%
  List<Map<String, Object>> fields = (List<Map<String, Object>>) request.getAttribute("fields");
  if (fields != null) {
    for (Map<String, Object> field:fields) {
      int valueType = Util.str2Int(field.get("ValueType"));
      String initValue = (String) field.get("InitValue");
%>
    <li>
      <div class='popbox'>
        <a class='open' href='#'><%=Util.HTMLEncode((String)field.get("CustomerFieldName"))%></a>
        <div class='collapse'>
          <div class='box'>
            <div class='arrow'></div><div class='arrow-border'></div>
            <form name="<%=Const.FIELD_KEY%><%=field.get("CustomerFieldId")%>" valueType="<%=valueType%>">
              <p class="fields">
                <%if (valueType == Const.FIELD_TYPE_DATE) {%>
                <span><%=Util.HTMLEncode((String)field.get("CustomerFieldName"))%>：</span><input class="filter2 daterangepickerinput" id="<%=Const.FIELD_KEY%><%=field.get("CustomerFieldId")%>" name="<%=Const.FIELD_KEY%><%=field.get("CustomerFieldId")%>" type="text" />
                <input name="commit" class="button" type="submit" value="查找" />
                <%} else if (valueType == Const.FIELD_TYPE_SELECT || valueType == Const.FIELD_TYPE_CHECKBOX) {%>
                <select>
                <option value="">请选择</option>
               <%
                if (initValue != null && initValue.length() > 0) {
                  String[] arr = initValue.split(",");
                  for (String v:arr) { %>
                <option value="<%=Util.HTMLEncode(v)%>"><%=Util.HTMLEncode(v)%></option>
               <%  }
                }%>
               </select> <input name="commit" class="button" type="submit" value="查找" />
               <%} else if (valueType == Const.FIELD_TYPE_NUMBER) { %>
                <input class="filter3" type="text" /> <span>至</span> <input class="filter3" type="text" /> <input name="commit" class="button" type="submit" value="查找" />
                <%} else {%>
                <input class="filter" type="text" /> <input name="commit" class="button" type="submit" value="查找" />
                <%}%>
              </p>
            </form>
          </div>
        </div>
      </div>
    </li>
<%
    }
  }
%>
    <li>
      <div class='popbox'>
        <a class='open' href='#'>全部</a>
        <div class='collapse'>
          <div class='box'>
            <div class='arrow'></div><div class='arrow-border'></div>
            <form name="phone" valueType="<%=Const.FIELD_TYPE_TEXT%>">
              <p class="fields">
                <input class="filter" name="all" type="text" /> <input name="commit" class="button" type="submit" value="查找" />
              </p>
            </form>
          </div>
        </div>
      </div>
    </li>
  </ul>
  <div class="clearfix"></div>
  <div class="searchitem" id="page_filter_selected"></div>
</div>